<template>
	<view>
		<view @tap="clickAction" class="bg-white radius shadow-blur">
			<view class="flex justify-start align-start">
				<view class="flex justify-start align-center padding-left padding-top padding-bottom" style="flex-direction: column;">
					<view class="radius padding-bottom-xs">
						<image class="radius" :src="voucher.forum.icon" style="width:66px;height:66px;">
						</image>
					</view>
				</view>
				<view class="padding flex justify-between align-center" style="width: 100%;">
					<view class="flex justify-start align-start" style="flex-direction: column;">
						<view class="flex justify-between align-center" style="width: 100%;">
							<text class="text-lg text-bold">《{{voucher.forum.name}}》的订阅券</text>
							<view  v-if="finishGet" class="padding-left-sm">
								<view class="cu-tag line-cyan sm">已领取</view>
							</view>
							<view v-else class="padding-left-sm">
								<button @click.stop="getVocherAction" class="cu-btn bg-gradual-blue sm radius">领取</button>
							</view>
						</view>
						<text class="text-df text-grey padding-top-sm padding-bottom-sm">授权码前缀:<text
								class="text-df text-black">{{voucher.sn_prefix}}</text></text>
						<view class="flex justify-start align-center">
							<view v-if="voucher.price > 0">
								<text class="text-df padding-right-sm">该券价值:<text
										class="text-price text-red">{{voucher.price/100}}元</text></text>
							</view>
							<text class="text-df text-grey">剩余:<text
									class="text-orange text-df">{{voucher.left_count}}</text>张</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "ForumVoucherDetail",
		data() {
			return {

			};
		},
		props: {
			voucher: {
				type: Object,
				default:{}
			},
			finishGet: {
				type:Boolean,
				default:false
			}
		},
		methods: {
			getVocherAction() 
			{
				if(this.finishGet) {
					uni.showToast({
						icon:'none',
						title:'不要重复领取!'
					})
				}
				this.$emit('getNow')
			},
			clickAction() {
				this.$emit('click')
			}
		},
	}
</script>

<style lang="scss">

</style>
